// 用户页面

// action
const GET_LIST = "INDEX/USER_INFO";

const changeUserInfo = data => ({
  type: GET_LIST,
  data
})
export const getUserInfo = server => {
  return (dispatch, getStore, $axios) => {
    return $axios.get("/api/user/info")
      .then(resp => {
        const { data } = resp.data;
        dispatch(changeUserInfo(data))
      })
  }
};

const defaultState = {
  userinfo: {}
}

export default (state = defaultState, action) => {
  switch (action.type) {
    case GET_LIST:
      const newState = {
        ...state,
        userinfo: action.data
      }
      return newState
    default:
      return state
  }
}